package longshu.srpc.client.impl;

import lombok.extern.slf4j.Slf4j;
import longshu.srpc.api.RpcService;
import longshu.srpc.client.RpcClient;
import longshu.srpc.client.RpcProxy;

@Slf4j
public class SimpleRpcClient implements RpcClient {
    private RpcProxy rpcProxy;

    public SimpleRpcClient(RpcProxy rpcProxy) {
        this.rpcProxy = rpcProxy;
    }

    @Override
    public <T extends RpcService> T refer(Class<? extends RpcService> serviceInterface) {
        log.info("serviceInterface: {}", serviceInterface);
        T rpcService = rpcProxy.getProxy(serviceInterface);
        return rpcService;
    }

}
